package logic.characters;

import logic.enemies.Enemy;
import logic.pruebas.GamePanel;
import logic.threads.ShootBullet;

/**
 * @author Unai
 * Su especial se mantiene. Se vuelve invulnerable
 *
 */
public class Snake extends Player {
	private static final long serialVersionUID = -6056109025834145773L;

	public Snake(int x, int y, GamePanel panel, String nomImg, int salud, int attack, int defense, int magic, int resistance, int speed, int jump, int stamina, int[] abilitiesIDs ) {
		super(x, y, panel, nomImg, salud, attack, defense, magic, resistance, speed, jump, stamina, abilitiesIDs);
		specialCost = 5;
		shootCost = 2;
		staminaRecovery = 2;
		lifeRecovery = 1;
		widthDifference = 15;
		heightDifference = 15;
		collisionWidth = 15;
		collisionHeight = altura - heightDifference;
		attackTime = 400;
		shootTime = 500;
	}

	public void shoot() {
		Runnable shootBullet = new ShootBullet(collisionX, collisionY, panelJuego, lookingRight, enemies, blocks, magic, true, this, shootTime);
		Thread fThread = new Thread(shootBullet);
		fThread.start();
		
	}
	
	public void specialEffect(Enemy enemy) {
		//Nothing
	}
	
	public void special() {
		
		if (stamina >= specialCost) {
		if (!attacking && !jumping && !throwing) {
			
		velX = 0;
		special = true;
		reduceStamina();
		movementAllowed = false;
		if (lookingRight) {
				updateIcon("resources" + getClass().getSimpleName() + "/SR.gif");
			}
		} else {
				updateIcon("resources" + getClass().getSimpleName() + "/SL.gif");
		}
		lastActionTime = System.currentTimeMillis();
		dibujar();
		} else {
			endSpecial();
		}
	}
	
	public void endSpecial() {
		
			if (!jumping && !attacking && !throwing) {
				if (lookingRight) {
					updateIcon("resources" + getClass().getSimpleName() + "/IR.gif");
					dibujar();
					movementAllowed = true;
					special = false;
				} else {
					updateIcon("resources" + getClass().getSimpleName() + "/IL.gif");
					dibujar();
					movementAllowed = true;
					special = false;
				}
			}
		}

}
